//
//  HDCFTabbarController.m
//  HaoDeCaiFu
//
//  Created by 郑开宏 on 2017/10/28.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "HDCFTabbarController.h"
#import "HDCFNavController.h"
#import "HDCFWisdomController.h"
#import "HDCFMineViewController.h"
#import "HDCFMangerMoneyController.h"
#import "ShoppingCarViewController.h"
@interface HDCFTabbarController ()
@end

@implementation HDCFTabbarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    HDCFWisdomController *wisdomVc = [[HDCFWisdomController alloc] init];
    wisdomVc.view.backgroundColor = [UIColor whiteColor];
    [self addChildVc:wisdomVc title:@"智投" image:@"zhitou_dis" selectedImage:@"zhitou_sel"];
    
    HDCFMangerMoneyController *mangerMVc = [[HDCFMangerMoneyController alloc] init];
    [self addChildVc:mangerMVc title:@"理财" image:@"licai_dis" selectedImage:@"licai_sel"];
    
    ShoppingCarViewController *shoppingCarVc = [[ShoppingCarViewController alloc] init];
    [self addChildVc:shoppingCarVc title:@"购物车" image:@"shoppingCar_dis" selectedImage:@"shoppingCar_sel"];
    
    HDCFMineViewController *mineVc = [[HDCFMineViewController alloc] init];
    [self addChildVc:mineVc title:@"我的" image:@"wode_dis" selectedImage:@"wode_sel"];
    
    
}

- (void)addChildVc :(UIViewController *)childVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    [childVc setTitle:title];
    //设置控制器的图片
    childVc.tabBarItem.image = [UIImage imageNamed:image];
    childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    //设置文字的颜色样式
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = ZKcolor(187, 187, 187);

    NSMutableDictionary *selectdTextAttrs = [NSMutableDictionary dictionary];
    selectdTextAttrs[NSForegroundColorAttributeName] = ZKcolor(198, 47, 47);
    [childVc.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [childVc.tabBarItem setTitleTextAttributes:selectdTextAttrs forState:UIControlStateSelected];
    
    HDCFNavController *nav = [[HDCFNavController alloc] initWithRootViewController:childVc];
    
    [self addChildViewController:nav];
}

@end
